/**
 * Created by ZT on 2018/5/7 0007.
 */
var machineVue = new Vue({
      el:'#machineVue',
     data:{
         dataTable:[],
         searchText:'',
         row:{
             page:1, //当前页
             per_page:20, //每页行数,
             total:''
         },
         select:[
             20,50,100,200
         ]
     },
    mounted:function () {
           this.load();
    },
    methods:{
       load:function () {
           var target =this;
           $('[data-am-selected]').selected({
               btnWidth: '200px',
               btnSize: 'sm',
               btnStyle: 'secondary',
               dropUp:1
           });
           var $selected = $('#userSelect');
           $selected.on('change', function() {
               target.row.per_page = $(this).find('option').eq(this.selectedIndex).text();
               target.refresh();
           });
           target.refresh();
       },
        refresh:function () {
            var target = this;
            var url = 'machines';
            this.fetch({
                url : url,
                methods : 'GET',
                params:{
                    page : target.row.page,
                    per_page : target.row.per_page,
                    name : this.searchText
                },
            }).then(function (response) {
                var paginationTable = $("#pagination");
                initPagination(response,url,paginationTable,target);
            });
        },
        searchUser:function () {
            var target = this;
            target.refresh();
        },

    }


});